package com.tvshows.structure.beans;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;

/**
 * This class contains the Favorite show details.
 */

@Entity( name = "Favorite" )
@OnDelete( action = OnDeleteAction.CASCADE )
@NamedQueries( {
    @NamedQuery( name = "favorite.loadBySchedule", query = "SELECT f from Favorite f where f.scheduleFavorite =:schedule order by nameFavorite" ),
    @NamedQuery( name = "favorite.loadAll", query = "SELECT f from Favorite f" ),
    @NamedQuery( name = "favorite.byName", query = "SELECT f from Favorite f where nameFavorite=:name" ) } )
public class Favorite
    implements Serializable
{

    /**
     * 
     */
    private static final long serialVersionUID = 2573299001113981763L;

    @Id
    @Column( name = "ID" )
    @GenericGenerator( name = "gen", strategy = "increment" )
    @GeneratedValue( generator = "gen" )
    private int id;

    @Column( name = "SEASON_NUM", nullable = false )
    private String seasonNumber;

    @Column( name = "LAST_EPISODE_NUM", nullable = false )
    private String lastEpisodeNumber;

    @Column( name = "NAME", nullable = false, unique = true )
    private String nameFavorite;

    @Column( name = "SCHEDULE" )
    private String scheduleFavorite;

    @OneToMany( cascade = { CascadeType.ALL }, orphanRemoval = true, fetch = FetchType.LAZY, mappedBy = "favorite" )
    private Set<Historique> historiques = new HashSet<Historique>();

    public Favorite()
    {
    }

    public String getSeasonNumber()
    {
        return seasonNumber;
    }

    public void setSeasonNumber( String seasonNumber )
    {
        this.seasonNumber = seasonNumber;
    }

    public String getLastEpisodeNumber()
    {
        return lastEpisodeNumber;
    }

    public void setLastEpisodeNumber( String lastEpisodeNumber )
    {
        this.lastEpisodeNumber = lastEpisodeNumber;
    }

    public String getNameFavorite()
    {
        return nameFavorite;
    }

    public void setNameFavorite( String nameFavorite )
    {
        this.nameFavorite = nameFavorite;
    }

    /**
     * @return the scheduleFavorite
     */
    public String getScheduleFavorite()
    {
        return scheduleFavorite;
    }

    /**
     * @param scheduleFavorite the scheduleFavorite to set
     */
    public void setScheduleFavorite( String scheduleFavorite )
    {
        this.scheduleFavorite = scheduleFavorite;
    }

    /**
     * @return the id
     */
    public int getId()
    {
        return id;
    }

    /**
     * @param id
     */
    public void setId( int id )
    {
        this.id = id;
    }

    public Set<Historique> getHistoriques()
    {
        return historiques;
    }

}